<?php

namespace App\Models;

use App\Services\MyPimpableTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;


class TestList extends Model
{
    use HasFactory, MyPimpableTrait;

    protected $searchable = ['name','paper_id','subject_id'];

    protected $vague = ['name'];

    protected $fillable = ['id', 'name', 'user_id', 'paper_id', 'subject_id', 'type', 'status', 'order', 'random', 'fixed', 'artificial'];

    protected $casts = [
        'random' => 'array',
        'fixed' => 'array'
    ];

    public function user()
    {
        return $this->belongsTo(User::class, 'user_id', 'id');
    }

    // 试卷分类关联
    public function paper()
    {
        return $this->belongsTo(Category::class, 'paper_id', 'id');
    }

    // 试卷科目关联
    public function subject()
    {
        return $this->belongsTo(Category::class, 'subject_id', 'id');
    }
}
